<template>
  <div>
    <van-search
      v-model="searchw"
      show-action
      label="地址"
      placeholder="请输入搜索关键词"
    >
      <template #action>
        <div @click="onClickButton">搜索</div>
      </template>
    </van-search>
    <van-card
      v-for="item in searchApiData"
      :num="item.goods_number"
      :price="item.goods_price"
      desc="描述信息"
      :title="item.goods_name"
      :thumb="
        item.goods_big_logo
          ? item.goods_big_logo
          : ' https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg'
      "
    />
  </div>
</template>

<script setup>
import { ref, watch } from "vue";
let searchw = ref("");
import { searchApi } from "@/api/api";
let searchApiData = ref([]);
watch(searchw, (val) => {
  console.log(val);
  searchApi(val).then((res) => {
    console.log(res);
    searchApiData.value = res.data.message.goods;
  });
});
</script>

<style lang="scss" scoped>
</style>